package com.chj.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.chj.entity.ProductEntiry;

import java.util.HashMap;
import java.util.Map;

@Service
public class ProductServiceImpl implements ProductService {
    private static Map<String,ProductEntiry> productMap = new HashMap<>();
    static {
        ProductEntiry product = new ProductEntiry();
        product.setId("P001");
        product.setName("iponex");
        product.setPrice(10000);
        productMap.put(product.getId(),product);

        product = new ProductEntiry();
        product.setId("P002");
        product.setName("大疆无人机");
        product.setPrice(100000);
        productMap.put(product.getId(),product);
    }

    @Override
    public ProductEntiry getDetail(String id) {
        ProductEntiry product = productMap.get(id);
        return product;
    }

    @Override
    public ProductEntiry modify(ProductEntiry productEntiry) {
        ProductEntiry product = new ProductEntiry();
        product.setId(productEntiry.getId());
        product.setName(productEntiry.getName());
        product.setPrice(productEntiry.getPrice());
        productMap.put(product.getId(),product);
        return product;
    }

    @Override
    public boolean status(String id, boolean upDown) {
        return false;
    }
}
